﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web;
using Telerik.Web.UI;
using System.Data;

public partial class PlacesAroundCleveland : System.Web.UI.Page
{
    public double UserID = 0;
    public string Name = "";
    public string EmailID = "";
    public double PlaceId = 0;
    double ReviewID = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["FullName"].ToString() != "" || Session["UserID"].ToString() != "" || Session["EmailID"].ToString() != "")
            {
                Name = Session["FullName"].ToString();
                UserID = Convert.ToDouble(Session["UserID"].ToString());
                EmailID = Session["EmailID"].ToString();

            }
            else
            {
                Response.Redirect("frmLogin.aspx");
            }
        }
    }

    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        string STRSQL = "select * from PlaceReviews where PlaceID = 1 order by  CreatedDate desc ";

        DataTable dtbl = SocialKlee.BusinessLogicLayer.BOLyer.GetDataTable(STRSQL);

        if (dtbl.Rows.Count > 0)
        {
           

            RadGrid1.DataSource = dtbl;
        
        }

    }

    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {

        if (e.CommandName == "View")
        {

            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;

                ReviewID = Convert.ToDouble(e.CommandArgument.ToString());
                // string PlaceId1 = item["PlaceID"].ToString();

                //  PlaceId = Convert.ToDouble(item["PlaceID"].ToString());

                string strsql = "select * from PlaceReviews where ReviewID=" + ReviewID + " and Placeid =1 ";
                DataTable dtbl = SocialKlee.BusinessLogicLayer.BOLyer.GetDataTable(strsql);
                if (dtbl.Rows.Count > 0)
                {
                   // RadGrid2.Visible = true;
                   // RadGrid2.DataSource = dtbl;
                }
                else
                {
                   // RadGrid2.Visible = false;
                }

            }

        }


        if (e.CommandName == "Delete")
        {

            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;

                ReviewID = Convert.ToDouble(e.CommandArgument.ToString());
                

                string strsql = "delete from PlaceReviews where ReviewID=" + ReviewID;
               DataTable dtbl = SocialKlee.BusinessLogicLayer.BOLyer.GetDataTable(strsql);

            }
        }

    }
}